/-app
/-docs
/-files
/-imports ...
/-imports/codemirror ...
codemirror.css
codemirror.js
/-imports/jquery
/-imports/knockout
/-persistence
/-typings
errors.js
functions.ts
index.html
try.js
    var display = cm.display;
2658
    d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
2659
    cm.setSize();
2660
  }
2661
 
2662
  // MOUSE EVENTS
2663
 
2664
  // Return true when the given mouse event happened in a widget
2665
  function eventInWidget(display, e) {
2666
    for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
2667
      if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) return true;
2668
    }
2669
  }
2670
 
2671
  // Given a mouse event, find the corresponding position. If liberal
2672
  // is false, it checks whether a gutter or scrollbar was clicked,
2673
  // and returns null if it was. forRect is used by rectangular
2674
  // selections, and tries to estimate a character position even for
2675
  // coordinates beyond the right of the text.
2676
  function posFromMouse(cm, e, liberal, forRect) {
2677
    var display = cm.display;
2678
    if (!liberal) {
2679
      var target = e_target(e);
2680
      if (target == display.scrollbarH || target == display.scrollbarV ||
2681
          target == display.scrollbarFiller || target == display.gutterFiller) return null;
2682
    }
2683
    var x, y, space = display.lineSpace.getBoundingClientRect();
2684
    // Fails unpredictably on IE[67] when mouse is dragged around quickly.
2685
    try {
2686
      x = e.clientX - space.left; y = e.clientY - space.top;
2687
      if (!x && !y && e.touches && e.touches.length===1) {
2688
        x = e.touches[0].clientX - space.left;
2689
        y = e.touches[0].clientY - space.top;
2690
      }
2691
    } catch (e) { return null; }
2692
    var coords = coordsChar(cm, x, y), line;
2693
    if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
2694
      var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
2695
      coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
2696
    }
2697
    return coords;
2698
  }
2699
 
2700
  // A mouse down can be a single click, double click, triple click,
2701
  // start of selection drag, start of text drag, new cursor
2702
  // (ctrl-click), rectangle drag (alt-drag), or xwin
2703
  // middle-click-paste. Or it might be a click on something we should
2704
  // not interfere with, such as a scrollbar or widget.
2705
  function onMouseDown(e) {
2706
    if (signalDOMEvent(this, e)) return;
2707
    var cm = this, display = cm.display;
2708
    display.shift = e.shiftKey;
2709
 
2710
    if (eventInWidget(display, e)) {
2711
      if (!webkit) {
2712
        // Briefly turn off draggability, to allow widgets to do
2713
        // normal dragging things.
2714
        display.scroller.draggable = false;
2715
        setTimeout(function(){display.scroller.draggable = true;}, 100);
2716
      }
2717
      return;
2718
    }
2719
    if (clickInGutter(cm, e)) return;
2720
    var start = posFromMouse(cm, e);
2721
    window.focus();
2722
 
2723
    switch (e_button(e)) {
2724
    case 1:
2725
      if (start)
2726
        leftButtonDown(cm, e, start);
2727
      else if (e_target(e) == display.scroller)
2728
        e_preventDefault(e);
2729
      break;
2730
    case 2:
2731
      if (webkit) cm.state.lastMiddleDown = +new Date;
2732
      if (start) extendSelection(cm.doc, start);
2733
      setTimeout(bind(focusInput, cm), 20);
2734
      e_preventDefault(e);
2735
      break;
2736
    case 3:
2737
      if (captureRightClick) onContextMenu(cm, e);
2738
      break;
2739
    }
2740
  }
 
Updated 2014-9-25 3:38.